module.exports = function(t) {
    var e = {};
    function n(a) {
        if (e[a]) return e[a].exports;
        var r = e[a] = {
            i: a,
            l: !1,
            exports: {}
        };
        return t[a].call(r.exports, r, r.exports, n), r.l = !0, r.exports;
    }
    return n.m = t, n.c = e, n.d = function(t, e, a) {
        n.o(t, e) || Object.defineProperty(t, e, {
            enumerable: !0,
            get: a
        });
    }, n.r = function(t) {
        "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, {
            value: "Module"
        }), Object.defineProperty(t, "__esModule", {
            value: !0
        });
    }, n.t = function(t, e) {
        if (1 & e && (t = n(t)), 8 & e) return t;
        if (4 & e && "object" == typeof t && t && t.__esModule) return t;
        var a = Object.create(null);
        if (n.r(a), Object.defineProperty(a, "default", {
            enumerable: !0,
            value: t
        }), 2 & e && "string" != typeof t) for (var r in t) n.d(a, r, function(e) {
            return t[e];
        }.bind(null, r));
        return a;
    }, n.n = function(t) {
        var e = t && t.__esModule ? function() {
            return t.default;
        } : function() {
            return t;
        };
        return n.d(e, "a", e), e;
    }, n.o = function(t, e) {
        return Object.prototype.hasOwnProperty.call(t, e);
    }, n.p = "", n(n.s = 3);
}([ function(t, e) {
    t.exports = require("lucky-canvas");
}, function(t, e, n) {
    "use strict";
    e.__esModule = !0, e.getImage = function() {
        var t = this;
        return new Promise(function(e, n) {
            wx.canvasToTempFilePath({
                canvas: t.canvas,
                success: function(t) {
                    return e(t);
                },
                fail: function(t) {
                    return n(t);
                }
            });
        });
    };
    var a = wx.getSystemInfoSync().windowWidth, r = e.rpx2px = function(t) {
        return "string" == typeof t && (t = Number(t.replace(/[a-z]*/g, ""))), a / 750 * t;
    };
    e.changeUnits = function(t) {
        return Number(t.replace(/^(\-*[0-9.]*)([a-z%]*)$/, function(t, e, n) {
            switch (n) {
              case "px":
                e *= 1;
                break;

              case "rpx":
                e = r(e);
                break;

              default:
                e *= 1;
            }
            return e;
        }));
    }, e.resolveImage = function(t, e, n) {
        var a = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : "src", r = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : "$resolve", i = n.createImage();
        i.onload = function() {
            e[r](i);
        }, i.src = e[a];
    };
}, , function(t, e, n) {
    "use strict";
    var a = n(0), r = n(1);
    Component({
        properties: {
            width: {
                type: String,
                value: "600rpx"
            },
            height: {
                type: String,
                value: "600rpx"
            },
            rows: {
                type: String,
                optionalTypes: [ Number ],
                value: "3"
            },
            cols: {
                type: String,
                optionalTypes: [ Number ],
                value: "3"
            },
            blocks: {
                type: Array,
                value: []
            },
            prizes: {
                type: Array,
                value: []
            },
            buttons: {
                type: Array,
                value: []
            },
            defaultConfig: {
                type: Object,
                value: {}
            },
            defaultStyle: {
                type: Object,
                value: {}
            },
            activeStyle: {
                type: Object,
                value: {}
            },
            start: {
                type: null,
                value: function() {}
            },
            end: {
                type: null,
                value: function() {}
            }
        },
        data: {
            lucky: null,
            isShow: !1,
            luckyImg: "",
            showCanvas: !0
        },
        observers: {
            "prizes.**": function(t, e) {
                this.lucky && (this.lucky.prizes = t);
            },
            "buttons.**": function(t, e) {
                this.lucky && (this.lucky.buttons = t);
            }
        },
        ready: function() {
            var t = this;
            wx.createSelectorQuery().in(this).select("#lucky-grid").fields({
                node: !0,
                size: !0
            }).exec(function(e) {
                if (e[0] && e[0].node) {
                    var n = t.canvas = e[0].node, i = t.dpr = wx.getSystemInfoSync().pixelRatio, c = t.ctx = n.getContext("2d"), o = t.data;
                    n.width = e[0].width * i, n.height = e[0].height * i, c.scale(i, i), t.lucky = new a.LuckyGrid({
                        flag: "MP-WX",
                        ctx: c,
                        dpr: i,
                        width: e[0].width,
                        height: e[0].height,
                        setTimeout: setTimeout,
                        clearTimeout: clearTimeout,
                        setInterval: setInterval,
                        clearInterval: clearInterval,
                        unitFunc: function(t, e) {
                            return (0, r.changeUnits)(t + e);
                        },
                        afterStart: function() {
                            t.lucky.draw(), t.setData({
                                luckyImg: "",
                                showCanvas: !0
                            });
                        }
                    }, {
                        rows: o.rows,
                        cols: o.cols,
                        blocks: o.blocks,
                        prizes: o.prizes,
                        buttons: o.buttons,
                        defaultConfig: o.defaultConfig,
                        defaultStyle: o.defaultStyle,
                        activeStyle: o.activeStyle,
                        start: function() {
                            for (var e = arguments.length, n = Array(e), a = 0; a < e; a++) n[a] = arguments[a];
                            t.triggerEvent.apply(t, [ "start" ].concat(n));
                        },
                        end: function() {
                            for (var e = arguments.length, n = Array(e), a = 0; a < e; a++) n[a] = arguments[a];
                            t.triggerEvent.apply(t, [ "end" ].concat(n)), r.getImage.call(t).then(function(e) {
                                t.setData({
                                    luckyImg: e.tempFilePath
                                });
                            });
                        }
                    }), t.setData({
                        isShow: !0
                    });
                } else console.error("lucky-canvas 获取不到 canvas 标签");
            });
        },
        methods: {
            imgBindload: function(t) {
                var e = t.currentTarget.dataset, n = e.name, a = e.index, i = e.i, c = this.data[n][a].imgs[i];
                (0, r.resolveImage)(t, c, this.canvas);
            },
            imgBindloadActive: function(t) {
                var e = t.currentTarget.dataset, n = e.name, a = e.index, i = e.i, c = this.data[n][a].imgs[i];
                (0, r.resolveImage)(t, c, this.canvas, "activeSrc", "$activeResolve");
            },
            luckyImgLoad: function() {
                this.setData({
                    showCanvas: !1
                }), this.lucky.clearCanvas();
            },
            handleClickOfImg: function(t) {
                var e = this, n = t.changedTouches[0], a = n.clientX, r = n.clientY;
                wx.createSelectorQuery().in(this).select(".lucky-img").fields({
                    rect: !0
                }).exec(function(t) {
                    var n = t[0], i = n.left, c = n.top;
                    e.toPlay(a - i, r - c);
                });
            },
            handleClickOfCanvas: function(t) {
                var e = t.changedTouches[0], n = e.x, a = e.y;
                this.toPlay(n, a);
            },
            toPlay: function(t, e) {
                var n = this, a = this.ctx;
                this.data.buttons.forEach(function(r) {
                    r && (a.beginPath(), a.rect.apply(a, n.lucky.getGeometricProperty([ r.x, r.y, r.col || 1, r.row || 1 ])), 
                    a.isPointInPath(t * n.dpr, e * n.dpr) && n.lucky.startCallback());
                });
            },
            init: function() {
                var t;
                (t = this.lucky).init.apply(t, arguments);
            },
            play: function() {
                var t;
                (t = this.lucky).play.apply(t, arguments);
            },
            stop: function() {
                var t;
                (t = this.lucky).stop.apply(t, arguments);
            }
        }
    });
} ]);